package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 系评估结果表
 */
@JsonApiResource(type = "evaluateresult")
@Table(name = "tnb_evaluate_result")
@Entity
public class EvaluateResult extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private Customer customer;// 评估老人

	private String remark;// 备注

	private String result;// 评估建议

	private String score;// 分数

	private EvaluateModel model;// 评估模版

	private Employee user;// 评估人

	private List<EvaluateExamerAnswer> answers;// 答案

	private String name;// 评估名称

	private Integer batch;// 批次

	private EvaluateBatch evaluateBatch;// 所属批次

	private NursingLevel level;

	private String contents;

	private Integer completeStatus;

	// @Transient
	// @JsonApiToOne
	// @JsonApiIncludeByDefault //huibati
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "level_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public NursingLevel getLevel() {
		return level;
	}

	public void setLevel(NursingLevel level) {
		this.level = level;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "evalute_batchid", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public EvaluateBatch getEvaluateBatch() {
		return evaluateBatch;
	}

	public void setEvaluateBatch(EvaluateBatch evaluateBatch) {
		this.evaluateBatch = evaluateBatch;
	}

	@Column(name = "batch")
	public Integer getBatch() {
		return batch;
	}

	public void setBatch(Integer batch) {
		if (batch == null) {
			batch = 0;
		}
		this.batch = batch;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@JsonApiToOne
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "user_id", foreignKey = @ForeignKey(name = "null"))
	public Employee getUser() {
		return user;
	}

	public void setUser(Employee user) {
		this.user = user;
	}

	@Column(name = "score")
	public String getScore() {
		return score;
	}

	public void setScore(String score) {
		this.score = score;
	}

	@JsonApiToOne
	@ManyToOne
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "result")
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "model_id", foreignKey = @ForeignKey(name = "null"))
	public EvaluateModel getModel() {
		return model;
	}

	public void setModel(EvaluateModel model) {
		this.model = model;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, mappedBy = "result")
	public List<EvaluateExamerAnswer> getAnswers() {
		return answers;
	}

	public void setAnswers(List<EvaluateExamerAnswer> answers) {
		this.answers = answers;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "content")
	public String getContents() {
		return contents;
	}

	public void setContents(String content) {
		this.contents = content;
	}

	@Column(name = "complete_status")
	public Integer getCompleteStatus() {
		return completeStatus;
	}

	public void setCompleteStatus(Integer completeStatus) {
		this.completeStatus = completeStatus;
	}

}
